#ifndef HISTORYMESSAGEWIDGET_H
#define HISTORYMESSAGEWIDGET_H

#include <QDialog>
#include <QWidget>
#include <QLabel>
#include <QLayout>
#include <QPushButton>
#include <QMouseEvent>
#include <QPoint>
#include <QLineEdit>
#include <QRadioButton>
#include <QDateTime>
#include <QPainter>
#include <QPainterPath>
#include <QDateTimeEdit>
#include <QScrollArea>
#include <QScrollBar>

#include "model/data.h"

using model::Message;
using model::MessageType;
using model::UserInfo;

/*********************************
 *  表示一个历史消息元素
 ********************************/
class Historyitem : public QWidget
{
    Q_OBJECT
public:
    Historyitem(){};

    static Historyitem* makeHistoryMsgItem(const Message& msg);
private:
};

/*********************************
 *  展示消息窗口
 ********************************/

class HistoryMessageWidget : public QDialog
{
    Q_OBJECT
public:
    HistoryMessageWidget(QWidget* parent);

    // 支持窗口拖动
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;

    // 绘制圆角
    void paintEvent(QPaintEvent *event) override;

    void initScrollArea();

    void addHistoryMessage(const Message& msg);

    void clear();


private:
    QPoint m_dragPosition;

    // 持有所有的历史消息结果的容器对象
    QWidget* container;
    QGridLayout* glayout;

    QLineEdit* searchEdit;
    QPushButton* searchBtn;
    QRadioButton* keyRadioBtn;
    QRadioButton* timeRadioBtn;
    QDateTimeEdit* begTimeEdit;
    QDateTimeEdit* endTimeEdit;

};

#endif // HISTORYMESSAGEWIDGET_H
